//
//  ViewController2.swift
//  demo
//
//  Created by Xiaoping Tang on 2023/3/17.
//

import UIKit

class ViewController2: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
//        self.isModalInPresentation = false
//        self.definesPresentationContext = true
//        self.modalPresentationStyle = .pageSheet
//        self.providesPresentationContextTransitionStyle = true
        
        
        self.view.backgroundColor = UIColor.gray
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        let vc = self.presentingViewController
        print("vc")
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        let vc = self.presentingViewController
        print("vc")
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */
    @IBAction func close(_ sender: Any) {
        self.dismiss(animated: true)
    }
    
    @IBAction func loading(_ sender: Any) {
        LoadingView.show()
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 3 ) {
            LoadingView.hide()
        }
    }
    
    @IBAction func showVC3(_ sender: Any) {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        
        let vc = storyboard.instantiateViewController(withIdentifier: "ViewController3")
        vc.modalPresentationStyle = .fullScreen
        self.navigationController?.pushViewController(vc, animated: true)
    }
}
